package time;

import java.time.Duration;
import java.time.LocalTime;

/**
 * 计算时间差
 */
public class DurationTest {
    public static void main(String[] args) {
        LocalTime now = LocalTime.now();
        LocalTime time = LocalTime.of(8, 8, 8);
        Duration duration = Duration.between(time, now);
        System.out.println("duration.toDays() = " + duration.toDays()); //相差天数
        System.out.println("duration.toHours() = " + duration.toHours());//相差小时数
        System.out.println("duration.toMinutes() = " + duration.toMinutes());//相差分钟
        System.out.println("duration.getSeconds() = " + duration.getSeconds());//相差秒
        System.out.println("duration.toMillis() = " + duration.toMillis());//相差毫秒数
    }
}
